package com.global.emc.spring.security.chain.command.password;

import com.global.emc.core.exception.impl.EMCException;
import com.global.emc.security.confidentiality.encrypt.TextEncryptor;
import com.global.emc.spring.method.support.chain.BeforeCallMethodContent;
import com.global.emc.spring.method.support.chain.command.AbstractBeforeCallMethodCommand;

/**   
 *  
 * @Description:  [一句话描述该类的功能]   
 * @Author:       [Joly_Huang]   
 * @CreateDate:   [2014年2月24日 下午4:30:01]   
 * @UpdateUser:   [Joly_Huang]   
 * @UpdateDate:   [2014年2月24日 下午4:30:01]   
 * @UpdateRemark: [说明本次修改内容]  
 * @Version:      [v1.0] 
 *    
 */
public class PasswordBCMCommand extends AbstractBeforeCallMethodCommand {
	
	private TextEncryptor textEncryptor;
	
	public TextEncryptor getTextEncryptor() {
		return textEncryptor;
	}
	
	public void setTextEncryptor(TextEncryptor textEncryptor) {
		this.textEncryptor = textEncryptor;
	}


	public void execute(BeforeCallMethodContent content) throws EMCException {
		UserPassword userPassword = super.findObject(content, UserPassword.class);
		String password = textEncryptor.encrypt(userPassword.getPassword());
		userPassword.setPassword(password);
	}

}
